#include "chatwindow.h"
#include "ui_chatwindow.h"
#include "QDebug"
chatWindow::chatWindow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::chatWindow)
{
    ui->setupUi(this);

    // Hardcode the AddBuddy attributes
    ui->sendButton->setIcon(QIcon(":icons/send.png"));
    ui->sendButton->setIconSize(QSize (51,41));
    ui->sendButton->setFlat(true);


    // Hardcode the AddBuddy attributes
   // ui->downloadButton->setIcon(QIcon(":icons/download"));
  //  ui->downloadButton->setIconSize(QSize (51,41));
  //  ui->downloadButton->setFlat(true);
}

chatWindow::~chatWindow()
{

    delete ui;

}

void chatWindow::on_sendButton_clicked()
{
             ui->outputWindow->append(QTime::currentTime().toString(Qt::TextDate) + " " + this->fromUser + ": " + ui->inputWindow->toPlainText());

            this->informationSent.clear();
            this->informationSent.append(this->fromUser);
            this->informationSent.append(this->toUser);
            this->informationSent.append(ui->inputWindow->toPlainText());
            this->informationSent.append(QTime::currentTime().toString(Qt::TextDate));
             emit messageSent();
            if(!ui->inputWindow->toPlainText().isEmpty() && !ui->inputWindow->toPlainText().isNull())
            {
                ui->inputWindow->clear();
            }

}

QStringList chatWindow::getList()
{
    return this->informationSent;
}

void chatWindow::setToUser(QString toUser)
{
    this->toUser = toUser;
}

void chatWindow::setfromUser(QString fromUser)
{
    this->fromUser = fromUser;
}

QString chatWindow::getToUser()
{
    return this->toUser;
}

QString chatWindow::getFromUser()
{
    return this->fromUser;
}

void chatWindow::appendMessage(QString message,QString fromUser,QString time)
{
    QString mess = time + " " + fromUser + ": " + message;
    this->ui->outputWindow->append(mess);

}



